#include <functional>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

int main() {
  std::vector data{3, 1, 4, 1, 5, 9, 2, 6};

  std::cout << "exclusive sum(默认求和): ";
  std::exclusive_scan(data.begin(), data.end(),
                      std::ostream_iterator<int>(std::cout, " "), 0);
  std::cout << "\ninclusive sum(默认求和): ";
  std::inclusive_scan(data.begin(), data.end(),
                      std::ostream_iterator<int>(std::cout, " "));

  std::cout << "\n\nexclusive product(乘法): ";
  std::exclusive_scan(data.begin(), data.end(),
                      std::ostream_iterator<int>(std::cout, " "), 1,
                      std::multiplies<>{});
  std::cout << "\ninclusive product(乘法): ";
  std::inclusive_scan(data.begin(), data.end(),
                      std::ostream_iterator<int>(std::cout, " "),
                      std::multiplies<>{});
}
